package com.edu.juc.cas.atomic;

import com.edu.juc.bean.Student;

import java.util.concurrent.atomic.AtomicReference;

public class AtomicReferenceTest {
    public static void main(String[] args) {
        AtomicReference<Student> atomicReference = new AtomicReference<>();
        Student stu1 = new Student(1, "张三", "软件工程");
        Student stu2 = new Student(2, "李四", "软件工程");

        atomicReference.set(stu1);
        System.out.println(atomicReference.compareAndSet(stu1, stu2) + "\t" + atomicReference.get().toString());
        System.out.println(atomicReference.compareAndSet(stu1, stu2) + "\t" + atomicReference.get().toString());

    }
}
